<%@ page contentType="text/html;charset=UTF-8" pageEncoding="UTF-8"%>
<%@include file="/WEB-INF/jsp/include/taglibs.jsp"%>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
	<meta http-equiv="Content-Type" content="text/html; charset=UTF-8" />
	<title><%=system_name%> - 供应商管理</title>
	<%@include file="/WEB-INF/jsp/include/meta.jsp"%>
	
	<link href="<%=basePath%>css/public.css" rel="stylesheet" type="text/css">
	<link href="<%=basePath%>css/index.css" rel="stylesheet" type="text/css">
	<link href="<%=basePath%>css/common.css" rel="stylesheet" type="text/css" />
	<script src="<%=basePath%>js/common.js" type="text/javascript"></script>
	
	<script type="text/javascript" src="js/pagebar.js"></script>
	<script type="text/javascript" src="fram/engine.js" ></script>
	<script type="text/javascript" src="fram/util.js" ></script>
	<script type="text/javascript" src="fram/interface/supplierService.js"></script>
</head>

<body oncontextmenu='return false'>

	<!--left begin-->
    <div class="fl left">
    	<!--search begin-->
    	<form action="<%=basePath%>trade/supplierList" method="GET">
    	<div class="search">
        	<ul>
            	<li><input type="text" name="companyName" value="${searchCond.companyName}" size="20" class="input" /></li>
                <li><input name="搜索" type="submit" class="button" value="搜 索" /></li>
            </ul>
        </div>
        </form>
    	<!--search end-->
        <div id="clear"></div>
      <!--leftProductList begin-->
        <div class="leftProductList">
        	<div class="title">
        	<table width="220" border="0" align="center" cellpadding="2" cellspacing="1">
              <tr>
                <th width="27" align="center"><input type="checkbox" name="allSelectId" id="allSelectId" onclick="judgmentChecjBox('allSelectId','id')" /></th>
                <th>公司名称</th>
              </tr>
            </table>
          </div>
          <div class="list1">
			<c:forEach var="supplier" items="${supplierList}" varStatus="rowStatus">
            <dl>
            	<dt><input type="checkbox" value="${supplier.id}" name="id"/></dt>
                <dd><a href="<%=basePath%>trade/supplierRight?sid=${supplier.id}" target="actionFrame">${supplier.companyName}</a></dd>
                <c:if test="${rowStatus.index==0}">
                	<script>
                	window.parent.document.getElementById("actionFrame").src="<%=basePath%>trade/supplierRight?sid=${supplier.id}";
                	</script>
                </c:if>
            </dl>
          	</c:forEach>
          	<c:if test="${empty supplierList}">
		   	没有相关记录！
		    </c:if>
          </div>
          
    </div>
        <!--leftProductList end-->
        
        <!--totle begin-->
        <div class="totle">
        	<div class="fl">总数：<strong>${searchStat.totalCount}</strong> 条</div>
            <div class="fr Export">
            <c:if test="${sessionScope.memberSessionInfo.userType.value eq '0'}">
            	<a href="javascript:void(0)"><img src="images/leftBtn2.jpg" alt="导出EXCEL" onclick="exportExcel()"/></a>
            </c:if>
            </div>
        </div>
        <!--totle end-->
        
        <!--page begin-->
        <script type="text/javascript">
				var pageControl = new wpagebar('pageControl');
				pageControl.argName = "pageIndex";
				pageControl.pageCount = ${searchStat.pageCount};
				pageControl.loadPage();
		</script> 
        <div id="clear"></div>
        <!--page end-->

        <!--Operating begin-->
        <div class="Operating">
			<ul>
            	<li><input name="添 加" type="button" class="button" value="添 加" onclick="addSupplier()"/></li>
            	<li><input name="修 改" type="button" class="button" value="修 改" onclick="modifySuppliers()"/></li>
            	<c:if test="${sessionScope.memberSessionInfo.userType.value eq '0'}">
            	<li><input name="删 除" type="button" class="button" value="删 除" onclick="delsellMultiple()"/></li>
            	</c:if>
            </ul>
        </div>
        <div id="clear"></div>
        <!--Operating end-->


    
    </div>
	<!--left end-->

<script type="text/javascript">
function exportExcel(){			
	var ids = getSelectedCheckBoxValues('id');
	if(ids == "")
		alert("请先选择要导出的信息！");
	else {
		window.open("<%=basePath%>trade/exportExcel?t=3&ids="+ids);
	}
}
function addSupplier(){
	//loading(true);
	//WIN.show('<font size=5>添加产品信息</font>',$('winCon_1'),{width:600,height:450});
	window.parent.document.getElementById("actionFrame").src="<%=basePath%>trade/supplierEdit?action=add";
}
function modifySuppliers(){
	var objs = document.getElementsByName("id");	
	var ids=0;
	var vas='';
	for(var i=0;i<objs.length;i++){
		if(objs[i].checked){
			ids++;
			vas=objs[i].value;			
		}
	}
	if(ids!=1){
		alert("请选择一条且只能选择一条信息进行编辑！");
		return ;
	}	
	if(vas==''){
		alert("请先选择要操作的信息");
		return ;
	}else{
		modifySupplier(vas);
	}	
}
function modifySupplier(id){
	if(null==id||''==id){
		alert('请选择产品信息！');return;
	}
	//WIN.show('修改产品信息',$('winCon_1'),{width:600,height:450});
	//$("winDivFrame").src="<%=basePath%>trade/productEdit?action=modify&id="+id;
	window.parent.document.getElementById("actionFrame").src="<%=basePath%>trade/supplierEdit?action=modify&id="+id;
}
function delsellMultiple(){			
	var objs = document.getElementsByName("id");
	var ids='';	
	for(var i=0;i<objs.length;i++){
		if(objs[i].checked){
			ids+=objs[i].value+",";
		}
	}
	if(ids==''){
		alert("请先选择要操作的信息");
		return ;
	}
	ids = ids.substring(0,ids.length - 1);
	
	if(confirm("您确定要删除?")){
		if(ids == ""){
			alert("请先选择要删除的信息！");
			return false;
		}else{
			supplierService.deleteSupplierByIds(ids,{
				callback:function(f){alert("删除成功");reload();},
				exceptionHandler:function(message){alert("删除失败，请重试");},
				errorHander:function(err){}
			})
		}
	}
}
</script>
</body>
</html>
